package pile.pay.service.impl;

import pile.pay.entity.ChargingGold;
import pile.pay.mapper.ChargingGoldMapper;
import pile.pay.service.IChargingGoldService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import pile.pay.entity.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import pile.pay.utils.WebUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import pile.pay.entity.PageList;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;
import java.util.Arrays;
import pile.pay.params.chargingGold.DeleDTO;
import pile.pay.params.chargingGold.ListDTO;
/**
 * <p>
 * 充电金表 服务实现类
 * </p>
 *
 * @author 郭天义
 * @since 2024-06-28
 */
@Service
public class ChargingGoldServiceImpl extends ServiceImpl<ChargingGoldMapper, ChargingGold> implements IChargingGoldService {

    @Autowired
    private ChargingGoldMapper chargingGoldMapper;



   @Override
   public ResponseResult add(ChargingGold chargingGold) {
        chargingGoldMapper.insert(chargingGold);
        return new ResponseResult(200,"新增成功");
   }

    /**
     * 根据电站ID 用户ID  渠道 查询充电金余额
     * @param stationId
     * @param memberId
     * @param channel
     * @return
     */
    @Override
    public ChargingGold selectByStationId(Integer stationId, Integer memberId, Integer channel) {
        return chargingGoldMapper.selectByStationId(stationId, memberId, channel);

    }

    /**
     *  根据充电机余额表ID 修改余额 方法为 +  如果要扣除 直接金额取反
     * @param memberBalance
     * @param chargingGoldId
     */
    @Override
    public void updateBalanceById(BigDecimal memberBalance, Integer chargingGoldId) {
        chargingGoldMapper.updateBalanceById(memberBalance,chargingGoldId);
    }


}
